package com.yaofeng.mybatis.util;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

/**
 * base64编码 加密解密
 * Created by yaofeng on 2019/8/16.
 */
public class Base64Util {



    /**
     * 加密
     * @param str
     * @return
     * @throws UnsupportedEncodingException
     */
    public static  String Encoder(String  str) throws UnsupportedEncodingException {

        return   Base64.getEncoder().encodeToString(str.getBytes("utf-8"));
    }


    /**
     * 解密
     * @param str
     * @return
     * @throws UnsupportedEncodingException
     */
    public static  String Decoder(String  str) throws UnsupportedEncodingException {
    return  new String(Base64.getDecoder().decode(str),"utf-8") ;
    }



}
